import axios from 'axios';

let YOUR_APPID = '', YOUR_REDIRECT_URI = ''
const WX_AUTH_URL = `https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect?appid=${YOUR_APPID}&redirect_uri=${YOUR_REDIRECT_URI}&response_type=code&scope=snsapi_login&state=STATE#wechat_redirect`;

export async function getWxAuthUrl() {
  try {
    const response = await axios.get(WX_AUTH_URL);
    if (response.status === 200) {
      return response.data;
    } else {
      throw new Error('获取企业微信授权 URL 失败');
    }
  } catch (error) {
    console.error('获取企业微信授权 URL 出错：', error);
    throw error;
  }
}
